let main_box = document.querySelector("#main_box ul");

const xhr1 = new XMLHttpRequest();
xhr1.open("get","http://chst.vip:1234/api/getinlanddiscount",true);
xhr1.onload = function(){
    if(xhr1.status === 200){
        let res1 = JSON.parse(xhr1.responseText);
        console.log(res1);

        let main_boxs = "";

        res1.result.forEach(item => {
            main_boxs += `<li id="${item.productId}" class="ali">
                            <div class="img">
                                ${item.productImg}
                            </div>
                            <div class="title">
                                ${item.productName}
                            </div>
                            <p class="price">
                                ${item.productPrice}
                            </p>
                            <p class="from">
                                ${item.productFrom}|${item.productTime}
                            </p>
                        </li> `
        });
        main_box.innerHTML = main_boxs;

        let aLi = document.querySelectorAll('.ali');
        // console.log(aLi);
        aLi.forEach(item => {
            item.onclick = function(){
                let ID = item.id;
                console.log(ID);
                location.href = '../html/gnzkdata.html?productid='+ID
            }
        })
        // console.log($('#main_box ul li'))
    }
}
xhr1.send(null);


